package com.c.ctgproject.adapter.guang

import android.app.Activity
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.adapter.ImageCommonRvV2Adapter
import com.c.ctgproject.databinding.ItemBatteryImageListBinding
import com.c.ctgproject.entity.guang.PicUrlsBean
import com.c.ctgproject.entity.guang.PowerBatteryEntityV2
import com.c.ctgproject.utils.handlerNull

class BatteryImageAdapter(private val context: AppCompatActivity, private val mList: List<PicUrlsBean>) : RecyclerView.Adapter<BatteryImageAdapter.MyViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
        val view = ItemBatteryImageListBinding.inflate(LayoutInflater.from(context), parent, false)
        return MyViewHolder(view)
    }

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
        val data = mList[position]
        holder.mTextView.text = data.name.handlerNull()
        data.picList?.let { l ->
            holder.mRecyclerView.adapter = ImageCommonRvV2Adapter(context, l)
            holder.mRecyclerView.layoutManager = GridLayoutManager(context,3,GridLayoutManager.VERTICAL,false)
//            holder.mRecyclerView.layoutManager = LinearLayoutManager(context)
        }
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    inner class MyViewHolder(view: ItemBatteryImageListBinding) : RecyclerView.ViewHolder(view.root) {
        val mRecyclerView = view.mRecyclerView
        val mTextView = view.mTextView
        val mParentLL = view.mParentLL
    }
}

